const dbName = "social";
const dbPath = `_doc/${dbName}_sqlite.db`;

const Social = {
	isOpened: false,
	open: function() {
		this.isOpened = plus.sqlite.isOpenDatabase({
			name: dbName,
			path: dbPath
		});
		console.log("Social:" + this.isOpened);
		if (this.isOpened == false) {
			plus.sqlite.openDatabase({
				name: dbName,
				path: dbPath,
				success: function(e) {
					console.log('Succeed to openDatabase')
					Social.isOpened = true;
				},
				fail: function(e) {
					console.error('Failed to openDatabase: ' + JSON.stringify(e))
					Social.isOpened = false;
				}
			});
		}
	},
	close: function() {
		plus.sqlite.closeDatabase({
			name: dbName,
			success: function(e) {
				console.log('Succeed to closeDatabase')
				Social.isOpened = false;
			},
			fail: function(e) {
				console.error('Failed to closeDatabase: ' + JSON.stringify(e))
			}
		})
	}
}

export {
	dbName,
	Social
}